package cn.jingzhuan.fm.di.injection

import android.app.Activity
import cn.jingzhuan.fm.di.component.FMAudioCommentComponent
import cn.jingzhuan.fm.di.component.FMAudioComponent
import cn.jingzhuan.fm.di.component.FMAudioDocumentComponent
import cn.jingzhuan.fm.di.component.FMIndexComponent
import cn.jingzhuan.fm.di.scope.ActivityScope
import cn.jingzhuan.fm.ui.activity.*
import dagger.Binds
import dagger.Module
import dagger.android.ActivityKey
import dagger.android.AndroidInjector
import dagger.android.ContributesAndroidInjector
import dagger.multibindings.IntoMap

@Module(
        subcomponents =  [
            FMIndexComponent::class,
            FMAudioComponent::class,
            FMAudioDocumentComponent::class,
            FMAudioCommentComponent::class
        ])
abstract class ActivityModule {

    @Binds
    @IntoMap
    @ActivityKey(FMIndexActivity::class)
    internal abstract fun bindFMIndexActivityInjectorFactory(builder: FMIndexComponent.Builder): AndroidInjector.Factory<out Activity>

    @ActivityScope
    @ContributesAndroidInjector
    internal abstract fun contributesFMAlbumDetailActivityInjectFactory(): FMAlbumDetailActivity

    @Binds
    @IntoMap
    @ActivityKey(FMAudioActivity::class)
    internal abstract fun contributesFMAudioActivityInjectFactory(builder: FMAudioComponent.Builder): AndroidInjector.Factory<out Activity>

    @Binds
    @IntoMap
    @ActivityKey(FMAudioDocumentActivity::class)
    internal abstract fun contributesFMAudioDocumentActivityInjectFactory(builder: FMAudioDocumentComponent.Builder): AndroidInjector.Factory<out Activity>

    @Binds
    @IntoMap
    @ActivityKey(FMAudioCommentActivity::class)
    internal abstract fun contributesFMAudioCommentActivityInjectFactory(builder: FMAudioCommentComponent.Builder): AndroidInjector.Factory<out Activity>

}